prisma 검색시 undefined 조건은 필터링을 하지 않겠다는 의미와 같다
- aliases
- No value
- tags
- prisma/problemshooting
- description
- No value
- links
- https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/null-and-undefined 0180 Prisma 🌈
- status
- No value
- project
- false
- area
- false
- resource
- false
- title
- prisma 검색시 undefined 조건은 필터링을 하지 않겠다는 의미와 같다
- created
- 2025-06-27T09:53:40
- updated
- 2025-06-27T10:01:41
Note: Using
undefined as the value of any key in a Prisma Client query's parameter object will cause Prisma ORM to act as if that key was not provided at all.참고링크: https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/null-and-undefined
따라서, 아래 두 쿼리는 전혀 다른 동작을 보인다:
null => 정확히 null이 담겨있는 엔티티를 가져온다
const users = await prisma.user.findMany({
where: {
name: null,
},
})
undefined => name 필터링을 하지 않겠다.
const users = await prisma.user.findMany({
where: {
name: undefined,
},
})
// equivalent as
const users = await prisma.user.findMany()